<template>
	<view class="container">
		<view class="serBox">
				  <view class="title">学生姓名：</view>
				  <u-input
					@input='nameInput'
					placeholder="请输入学生姓名"
					border="surround"
					clearable
					v-model="queryParams.studentName"
				  ></u-input>
				<!--  <u-input
				      placeholder="请输入学生姓名"
				      border="surround"
				      clearable
					  v-model="name"
				  </u-input> -->
				 
		</view>
		
		<view @tap='toEwm(item)' v-for="(item,index) in stuList" :key="index" class="itemBox">
			<view class='item1'>{{item.studentName}}</view>
			<view class='item2'>性别：{{item.studentSex}}</view>
			<view class='item2'>档案号：{{item.studentId}}</view>
			<view class="item2">年级：{{item.gradeName}}</view>
			<view class="item2">班级：{{item.className}}</view>
			<view class="item2">
				是否筛查：
				<text v-if='item.isTest==0' style="color: red;">{{scArr[item.isTest]}}</text>
				<text v-else-if='item.isTest==1' style="color: green;">{{scArr[item.isTest]}}</text>
			</view>
			<view class="item2">学校：{{item.schooName}}</view>
		</view>
		<u-popup mode="center" :show="ewmShow" @close="ewmShow=false">
			<view style="display: flex;justify-content: center;align-items: center;flex-direction: column;padding-left:20rpx">
				<view style="margin-top: 10px;font-size: 44rpx;font-weight: 550;">{{stName}}</view>
			    <!-- <image :src="qrCodeBase64" mode="aspectFit"></image> -->
				<ayQrcode ref="qrcode" :modal="modal_qr" :url="code" @hideQrcode="hideQrcode" :height="200" :width="200" />
				<!-- <view v-html='qrCodeBase64'></view> -->
			  </view>
		</u-popup>
	</view>
</template>

<script>
	import { listScreenPlanInfo, getScreenPlanInfo, delScreenPlanInfo, addScreenPlanInfo, updateScreenPlanInfo,smScreenPlanAdd } from "@/api/files/screenPlanInfo";
	import {
			getDicts
		} from '@/api/system/dict/data.js'
		
	import QRCode from 'qrcode'
	import ayQrcode from "@/components/ay-qrcode/ay-qrcode.vue"
	export default {
		components: {
			ayQrcode,

		},
		data() {
			return {
				code:'',
				modal_qr: false,
				scArr:{
					0:'否',
					1:'是'
				},
				stName:'',
				qrCodeBase64:'',
				queryParams:{
					pageNum:1,
					pageSize:200
				},
				stuList:[],
				ewmShow:false,
			}
		},
		onLoad(e){
			this.queryParams.planNo = e.code
			listScreenPlanInfo(this.queryParams).then(res=>{
				this.stuList = res.rows
			})
		},
		methods: {
			toEwm(e){
				 // let _this = this;
				  this.stName = e.studentName
				  const student = e
				  const studentBirth = student.studentBirth ? student.studentBirth.replace(/-/g, '/') : '';
				  //const studentSex = (student.studentSex && student.studentSex.trim() === '女') ? 'F' : 'M';
				  const screenType='F';
				  const studentId=student.studentId;
				  const schoolInfo=student.gradeName+student.className;
				  const qrData = [
					'<<',
					student.planId,
					student.studentName,
					studentBirth,
					screenType,
					studentId,
					schoolInfo,
					'>>'
				  ].join(',');
				this.code = qrData
				this.modal_qr = true;
				this.$nextTick(()=>{
					this.$refs.qrcode.crtQrCode()
				})
				this.ewmShow = true
				this.modal_qr = false;
				
			},
			 hideQrcode() {
				this.modal_qr = false;
			},
			nameInput(item){
				this.queryParams.studentName = item
				listScreenPlanInfo(this.queryParams).then(res=>{
					this.stuList = res.rows
				})
			}
		
			
		}
	}
</script>

<style lang="scss" scoped>
	.container {
	  background-color: #F2F2F2;
	  min-height: 100vh;
	  padding: 20rpx;
	}
	.serBox{
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}
	.itemBox{
		width: 92%;
		margin: 0 auto;
		padding:10rpx 20rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		margin-top: 20rpx;
		.item1{
			font-size: 34rpx;
			font-weight: 600;
		}
	}
</style>
